package com.fuxian.dao.mybatisImpl;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.fuxian.dao.TeacherDao;
import com.fuxian.model.Teacher;
@Repository
public class TeacherDaoMybatisImpl implements TeacherDao {
	@Resource
	private SqlSessionTemplate sqlSessionTemplate;
	public void addTeacher(Teacher teacher) {
		sqlSessionTemplate.insert("addTeacher", teacher);

	}

	public void deleteTeacherById(int id) {
		sqlSessionTemplate.delete("deleteTeacherById", id);

	}

	public void modifyTeacher(Teacher teacher) {
		sqlSessionTemplate.update("modifyTeacher", teacher);

	}

	public List<Teacher> selectAllTeacher(int start,int size) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", start);
		map.put("size", size);
		List<Teacher>list=sqlSessionTemplate.selectList("selectAllTeacher", map);
		return list;
	}

	public List<Teacher> selectTeacherByCreatetime(Timestamp create_time,int start,int size) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", start);
		map.put("size", size);
		map.put("create_time", create_time);
		List<Teacher>list=sqlSessionTemplate.selectList("selectTeacherByCreatetime", map);
		return list;
	}

	public Teacher selectTeacherById(int id) {
		Teacher teacher=sqlSessionTemplate.selectOne("selectTeacherById", id);
		return teacher;
	}

	public List<Teacher> selectTeacherByName(String name) {
		List<Teacher>list=sqlSessionTemplate.selectList("selectTeacherByName", name);
		return list;
	}

	public List<Teacher> selectTeacherByEdubg(String edu_bg,int start,int size) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", start);
		map.put("size", size);
		map.put("edu_bg", edu_bg);
		List<Teacher>list=sqlSessionTemplate.selectList("selectTeacherByEdubg", map);
		return list;
	}
	
	public int selectTeacherCount(){
		return sqlSessionTemplate.selectOne("selectTeacherCount");
	}

}
